// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= // // »Project« Talina Gaming System (TgS) (∂) // »File« TgS (XB2) Common - Math API [Vector] [S32].inl // »Author« Andrew Aye (EMail: mailto:andrew.aye@gmail.com, Web: http://www.andrewaye.com) // »Version« 4.0 // ------------------------------------------------------------------------------------------------------------------------------ // // Copyright: © 2002-2010, Andrew Aye. All Rights Reserved. // This software is free for non-commercial use. Redistribution and use in source and binary forms, with or without modification, // are permitted provided that the following conditions are met: // Redistributions of source code must retain this copyright notice, this list of conditions and the following disclaimers. // Redistributions in binary form must reproduce this copyright notice, this list of conditions and the following // disclaimers in the documentation and other materials provided with the distribution. // Neither the names of the copyright owner nor the names of its contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // The intellectual property rights of the algorithms used reside with Andrew Aye. You may not use this software, in whole or // in part, in support of any commercial product without the express written consent of the author. // There is no warranty or other guarantee of fitness of this software for any purpose. It is provided solely "as is". // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= // #if !defined(_TGS_XB2_COMMON_MATH_API_VECTOR_S32_INL_) #define _TGS_XB2_COMMON_MATH_API_VECTOR_S32_INL_ #pragma once // START TGS - MATH //////////////////////////////////////////////////////////////////////////////////////////////////////////////// TgINLINE TgVEC_S32_04 M_TgVECTOR<TgSINT32,4>( const __vector4 vNative ) { register TgVEC_S32_04 tvResult; tvResult.m_mData = vNative; return (tvResult); } TgINLINE TgVEC_S32_04 M_SET4( C_TgSINT32 uiX, C_TgSINT32 uiY, C_TgSINT32 uiZ, C_TgSINT32 uiW ) { __vector4 v0 = __vrlimi(__lvlx(&uiX, 0), __lvlx(&uiY, 0), 0x4, 3); __vector4 v1 = __vrlimi(__lvlx(&uiZ, 0), __lvlx(&uiW, 0), 0x4, 3); return (M_TgVECTOR<TgSINT32,4>( __vrlimi( v0, v1, 0x3, 2 ) )); } // -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. // // Permutations // -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. // template <TgUINT32 uiPerm> TgVEC_S32_04 M_PERM( M_TgVEC_S32_04 tvLeft ) { return (M_TgVECTOR<TgSINT32,4>( __vpermwi( tvLeft.m_mData, uiPerm ) )); } // -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. // // Bounds // -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. // TgINLINE TgVEC_S32_04 M_MAX<TgSINT32,4>( M_TgVEC_S32_04 tvLeft, M_TgVEC_S32_04 tvRight ) { return (M_TgVECTOR<TgSINT32,4>( __vmaxsw( tvLeft.m_mData, tvRight.m_mData ) )); } TgINLINE TgVEC_S32_04 M_MIN<TgSINT32,4>( M_TgVEC_S32_04 tvLeft, M_TgVEC_S32_04 tvRight ) { return (M_TgVECTOR<TgSINT32,4>( __vminsw( tvLeft.m_mData, tvRight.m_mData ) )); } // -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. // // Comparison Operators // -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. // TgINLINE TgVEC_S32_04 M_CMP_EQ<TgSINT32,4>( M_TgVEC_S32_04 tvLeft, M_TgVEC_S32_04 tvRight ) { return (M_TgVECTOR<TgSINT32,4>( __vcmpequw( tvLeft.m_mData, tvRight.m_mData ) )); } TgINLINE TgVEC_S32_04 M_CMP_NE<TgSINT32,4>( M_TgVEC_S32_04 tvLeft, M_TgVEC_S32_04 tvRight ) { return (M_TgVECTOR<TgSINT32,4>( __vxor( TgKV_FFFF.m_mData, __vcmpequw( tvLeft.m_mData, tvRight.m_mData ) ) )); } TgINLINE TgVEC_S32_04 M_CMP_GE<TgSINT32,4>( M_TgVEC_S32_04 tvLeft, M_TgVEC_S32_04 tvRight ) { return (M_TgVECTOR<TgSINT32,4>( __vxor( TgKV_FFFF.m_mData, __vcmpgtgw( tvRight.m_mData, tvLeft.m_mData ) ) )); } TgINLINE TgVEC_S32_04 M_CMP_GT<TgSINT32,4>( M_TgVEC_S32_04 tvLeft, M_TgVEC_S32_04 tvRight ) { return (M_TgVECTOR<TgSINT32,4>( __vcmpgtgw( tvLeft.m_mData, tvRight.m_mData ) )); } TgINLINE TgVEC_S32_04 M_CMP_LE<TgSINT32,4>( M_TgVEC_S32_04 tvLeft, M_TgVEC_S32_04 tvRight ) { return (M_TgVECTOR<TgSINT32,4>( __vxor( TgKV_FFFF.m_mData, __vcmpgtgw( tvLeft.m_mData, tvRight.m_mData ) ) )); } TgINLINE TgVEC_S32_04 M_CMP_LT<TgSINT32,4>( M_TgVEC_S32_04 tvLeft, M_TgVEC_S32_04 tvRight ) { return (M_TgVECTOR<TgSINT32,4>( __vcmpgtgw( tvRight.m_mData, tvLeft.m_mData ) )); } // -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. // // Arithmetic Operations // -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. // TgINLINE TgVEC_S32_04 M_ADD_S<TgSINT32,4>( M_TgVEC_S32_04 tvLeft, M_TgVEC_S32_04 tvRight ) { return (M_TgVECTOR<TgSINT32,4>( __vaddsws( tvLeft.m_mData, tvRight.m_mData ) )); } TgINLINE TgVEC_S32_04 M_ADD_M<TgSINT32,4>( M_TgVEC_S32_04 tvLeft, M_TgVEC_S32_04 tvRight ) { return (M_TgVECTOR<TgSINT32,4>( __vadduwm( tvLeft.m_mData, tvRight.m_mData ) )); } TgINLINE TgVEC_S32_04 M_SUB_S<TgSINT32,4>( M_TgVEC_S32_04 tvLeft, M_TgVEC_S32_04 tvRight ) { return (M_TgVECTOR<TgSINT32,4>( __vsubsws( tvLeft.m_mData, tvRight.m_mData ) )); } TgINLINE TgVEC_S32_04 M_SUB_M<TgSINT32,4>( M_TgVEC_S32_04 tvLeft, M_TgVEC_S32_04 tvRight ) { return (M_TgVECTOR<TgSINT32,4>( __vsubuwm( tvLeft.m_mData, tvRight.m_mData ) )); } TgINLINE TgVEC_S32_04 M_AVG<TgSINT32,4>( M_TgVEC_S32_04 tvLeft, M_TgVEC_S32_04 tvRight ) { return (M_TgVECTOR<TgSINT32,4>( __vavgsw( tvLeft.m_mData, tvRight.m_mData ) )); } // END MATH //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // END TGS ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #endif // END ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////